/*
 * File:   Layer_List.h
 * Author: ranjeet
 *
 * Created on January 19, 2009, 12:19 AM
 */

#include "Layer.h"
#include "Debug.h"
#include <list>

#ifndef _LAYER_LIST_H
#define	_LAYER_LIST_H


class Layer_List {
    list<Layer *> m_layers;
    uint m_layerIndexCounter;
    uint m_layerCount;
    Mutex_Wrapper m_mutex;

protected:
    static Layer_List* instance;

public:
    int removeLayer(uint layer);
    int addLayer();
    static Layer_List* get_instance();
    static void destroy();
    Layer &operator[] (uint index);
    void lock();
    void unlock();
    list<Layer *>::iterator getListIteratorBegin();
    list<Layer *>::iterator getListIteratorEnd();
    void setVisible(uint index, bool visible);
    ~Layer_List();
    void clear();


protected:
    Layer_List();
};

inline void Layer_List::lock() {
    m_mutex.lock();
}

inline void Layer_List::unlock() {
    m_mutex.unlock();
}

inline list<Layer *>::iterator Layer_List::getListIteratorBegin()
{
    return m_layers.begin();
}

inline list<Layer *>::iterator Layer_List::getListIteratorEnd()
{
    return m_layers.end();
}

#endif	/* _LAYER_LIST_H */

